package com.zzt.mybatis.controller;

import com.zzt.mybatis.model.UserInfo;
import com.zzt.mybatis.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description
 * User: panda
 * Date: 2025-03-05
 * Time: 9:55
 */
@RequestMapping("/user")
@RestController
public class UserController {

    @Autowired
    private UserInfoService userInfoService;

    @RequestMapping("/getAllUser")
    public List<UserInfo> getAllUser() {
        return userInfoService.getAllUser();
    }

    @RequestMapping("/getUserInfoById")
    public UserInfo getUserInfoById(Integer id) {
        return userInfoService.getUserInfoById(id);
    }

    /**
     * 登录接口
     * @param username
     * @param password
     * @return  true：密码正确，false：密码错误
     */
    @RequestMapping("/login")
    public Boolean login(String username, String password){
        UserInfo userInfo = userInfoService.queryUserByUserNameAndPassword(username, password);
        return userInfo == null ? false : true;
    }

}
